package com.vaadin.demo.jsdemo;

import java.io.Serializable;
import java.util.ArrayList;

import com.vaadin.annotations.JavaScript;
import com.vaadin.ui.AbstractJavaScriptComponent;

@JavaScript({ "mylibrary.js", "mycomponent-connector.js" })
public class MyComponent extends AbstractJavaScriptComponent {
    public interface ValueChangeListener extends Serializable {
        void valueChange();
    }

    ArrayList<ValueChangeListener> listeners = new ArrayList<ValueChangeListener>();

    public void addListener(ValueChangeListener listener) {
        listeners.add(listener);
    }

    @Override
    protected MyComponentState getState() {
        return (MyComponentState) super.getState();
    }

    public String getValue() {
        return getState().getValue();
    }

    public void setValue(String value) {
        getState().setValue(value);
    }
}